#include <iostream>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
using namespace std;

int main()
{
    pid_t id = fork();
    if (0 == id)
    {
        int *p = nullptr;
        *p = 100; // 野指针
        exit(0);
    }
    int status = 0;
    waitpid(id, &status, 0);
    cout << "exit code: " << ((status >> 8) & 0xff) << endl;
    cout << "exit signal: " << (status & 0x7f) << endl;
    cout << "core dump flag: " << ((status >> 7) & 0x1) << endl;
    return 0;
}